﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using KaoWuYouLibs.Common;
using KaoWuYouLibs.Model;

namespace KaoWuYouLibs.Dal
{
    public class TestedPaperAccess
    {
        public bool SaveTestedPaper(byte[] Answers, int Mark, string TestTaker, int TestPaperID)
        {
            SqlConnection conn = new SqlConnection(Tools.ConnString);
            try
            {
                conn.Open();
                SqlCommand cmd = conn.CreateCommand();

                cmd.CommandText = @"INSERT INTO TestedPaper(Answers,Mark,TestTaker,TestPaperID) 
                 VALUES(@Answers,@Mark,@TestTaker,@TestPaperID)  ";
                cmd.Parameters.AddRange(new SqlParameter[]
                    {
                        new SqlParameter("@Answers",Answers),
                        new SqlParameter("@Mark",Mark),
                        new SqlParameter("@TestTaker",TestTaker),
                        new SqlParameter("@TestPaperID",TestPaperID),
                    });
                cmd.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
            finally
            {
                conn.Close();
            }
        }
    }
}
